package xyz.luckyli.springcloud;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/**
 * ClassName:DeptProvider_8001
 * Package:xyz.luckyli.springcloud
 * Description:
 *
 * @Date:2020/9/29 14:50
 * @Author:857251389@qq.com
 */

/**
 * 自动注册到Eureka
 */
@EnableEurekaClient
@SpringBootApplication
@EnableDiscoveryClient
/**
 * 添加对熔断的支持
 */
@EnableCircuitBreaker
public class DeptProvider_hystrix_8001 {

    public static void main(String[] args) {
        SpringApplication.run(DeptProvider_hystrix_8001.class,args );
    }

    @Bean
    public ServletRegistrationBean getServlet(){
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());

        registrationBean.addUrlMappings("/actuator/hystrix.stream");

        return registrationBean;
    }

}
